import { MsgDoctorMsg } from '@/service/api/message'
import { IGetMsgList } from '@/service/api/message/type'
import initData from '../fnInitData'
import { Module } from 'vuex'
import { IMsgList } from './types'

const user: Module<IMsgList, any> = {
  namespaced: true,
  state() {
    return {
      message: initData('message', 'message') || []
    }
  },
  mutations: {
    saveMsg(state, data) {
      state.message = data
    }
  },
  actions: {
    getMsg({ commit }, postData: IGetMsgList) {
      MsgDoctorMsg(postData).then((res) => {
        commit('saveMsg', res.data.items)
      })
    }
  }
}

export default user
